﻿using System;
using System.Web.Security;

namespace PB.FBConnect
{
    public class FBUser : MembershipUser
    {
        #region Public Properties
        public facebook.Schema.user FacebookUser { get; set; }
        public CustomIdentity CustomUser { get; set; }
        #endregion

        #region Constructor
        public FBUser()
        {

        }

        public FBUser(CustomIdentity cUser)
            : base(Membership.Provider.Name, cUser.FacebookUserId.ToString(), cUser.FacebookUserId,
                                    string.Empty, string.Empty, string.Empty, !cUser.IsLocked, cUser.IsLocked,
                                    new DateTime(), new DateTime(), new DateTime(), new DateTime(), new DateTime())
        {
            this.CustomUser = cUser;
        }

        public FBUser(facebook.Schema.user fbsUser)
            : base(Membership.Provider.Name, fbsUser.uid.ToString(),fbsUser.uid.Value,
                                    string.Empty, string.Empty, string.Empty, true, false,
                                    new DateTime(), new DateTime(), new DateTime(), new DateTime(), new DateTime())
        {
            this.FacebookUser = fbsUser;
        }

        public FBUser(CustomIdentity cUser, facebook.Schema.user fbsUser)
            : base(Membership.Provider.Name, fbsUser.uid.ToString(), fbsUser.uid.Value,
                                    string.Empty, string.Empty, string.Empty, true, false,
                                    new DateTime(), new DateTime(), new DateTime(), new DateTime(), new DateTime())
        {
            if (cUser.FacebookUserId == fbsUser.uid.Value)
            {
                CustomUser = cUser;
                FacebookUser = fbsUser;
            }
            else
            {
                throw new Exception("Invalid Objects, FBUser object cannot be created");
            }
        }

        #endregion


    }

    
}
